package jy.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * Ofood entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "ofood", catalog = "waimai")
public class Ofood implements java.io.Serializable {

	// Fields

	private Integer id;
	private Order order;
	private Food food;
	private String name;
	private Float price;
	private Integer amount;

	// Constructors

	/** default constructor */
	public Ofood() {
	}

	/** minimal constructor */
	public Ofood(Order order, String name, Float price, Integer amount) {
		this.order = order;
		this.name = name;
		this.price = price;
		this.amount = amount;
	}

	/** full constructor */
	public Ofood(Order order, Food food, String name, Float price,
			Integer amount) {
		this.order = order;
		this.food = food;
		this.name = name;
		this.price = price;
		this.amount = amount;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "order_id", nullable = false)
	public Order getOrder() {
		return this.order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "food_id")
	public Food getFood() {
		return this.food;
	}

	public void setFood(Food food) {
		this.food = food;
	}

	@Column(name = "name", nullable = false, length = 40)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "price", nullable = false, precision = 12, scale = 0)
	public Float getPrice() {
		return this.price;
	}

	public void setPrice(Float price) {
		this.price = price;
	}

	@Column(name = "amount", nullable = false)
	public Integer getAmount() {
		return this.amount;
	}

	public void setAmount(Integer amount) {
		this.amount = amount;
	}

}